
#ifndef _ROBOEXCHANGE_H__
#define _ROBOEXCHANGE_H__

#include <QMap>
#include <QObject>
#include <QIODevice>
#include <QJsonArray>
#include <QMessageBox>
#include <QJsonDocument>
#include <QThreadPool>
#include <QThread>

#include "MotionAPI.hpp"
#include "RobotBase.hpp"

NAMESPACE_BEGIN(NSRobotExchange)

class MOTIONAPI RobotExchange : public QObject {
	Q_OBJECT
	SIGNALDEC(RobotExchange, QObject)
public:
	void readRobotConfigs(const QString filename);
	NSRobotBase::RobotBase* getRobot(int id) { 
		if (m_robots.contains(id)) {
			return m_robots.value(id);
		}
		return nullptr;
		};
	int getRobotCount() { return m_robots.size(); };

public Q_SLOTS:
	void importedRobotEvent(NSRobotBase::RobotBase* robotbase);
	void importRobotFile(const QString filename, int center_widget_id);

Q_SIGNALS:
	void ImportStarted(QThread* thread);
	void ImportQuited(QThread* thread);
	void importedRobotSignal(NSRobotBase::RobotBase* robotbase);

protected:
	void Initialize();
	void Finalize();

protected:
	int model_id;
	QMap<int, NSRobotBase::RobotBase*> m_robots;

};

NAMESPACE_END

#endif // !_ROBOEXCHANGE_H__



